package com.oauth.service.linkedin;

import com.oauth.service.OAuthDAO;
import com.oauth.service.OAuthService;
import com.oauth.service.OAuthServiceException;
import com.oauth.service.linkedin.beans.LinkedinBean;

public class LinkedinServiceImpl implements OAuthService<LinkedinBean> {

	private OAuthDAO<LinkedinBean> mLinkedinDAO;
	
	@Override
	public void deleteToken(Long memberId) throws OAuthServiceException {
		getLinkedinDAO().deleteToken(memberId);
	}

	@Override
	public LinkedinBean getToken(Long memberId) throws OAuthServiceException {
		return getLinkedinDAO().getToken(memberId);
	}

	@Override
	public LinkedinBean persistToken(LinkedinBean serviceBean) throws OAuthServiceException {
		if (serviceBean.getMemberId() == null
				|| serviceBean.getAccessToken() == null
				|| serviceBean.getAccessTokenSecret() == null) {
			throw new OAuthServiceException("Parameters are null" + serviceBean);
		}
		return getLinkedinDAO().persistToken(serviceBean);
	}

	/**
	 * @return the linkedinDAO
	 */
	public OAuthDAO<LinkedinBean> getLinkedinDAO() {
		return mLinkedinDAO;
	}

	/**
	 * @param pLinkedinDAO the linkedinDAO to set
	 */
	public void setLinkedinDAO(OAuthDAO<LinkedinBean> pLinkedinDAO) {
		mLinkedinDAO = pLinkedinDAO;
	}

	
	
}
